// 联合类型
let str: string | number
str = 18
str = 'aaa'
console.log(str);

// 一个数组可以是字符串、数字、布尔
const arr1: (string | number | boolean)[] = ['张三', '李四', false, 35]
const arr2: Array<string | number | boolean> = ['张三', '李四', false, 35]
console.log(arr1, arr2);

// 类型别名
// 通过type关键字 用来简化和复用类型
type myArr = (string | number | boolean)[]
const arr3: myArr = ['张三', '李四', false, 35]
const arr4: myArr = ['张三', 35]
console.log(arr3, arr4);

let test: number | string[] = 20
test = ['11', 'aa']
console.log(test);

